package stream;


import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class iterate {
    public static void main(String[] args) {
        Stream.iterate(1,i ->i +1)
                .limit(100)
                .map(i1 ->{
                    try {
                        return readLine(i1);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }).collect(Collectors.toList());
    }

    public static User readLine(int i) throws Exception {
        if (new Random().nextInt(100) <= 50) {
            return new User("zh",10,1);
        } else {
            throw new Exception("dadsa");
        }
    }
}
